<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="submit" value="单机" onclick="show()">
    <br>

    <input type="button" value="-" onclick="subtract()">
    <input type="text" style="width: 20px"  onkeyup="alter1()" onblur="update()" id="num" name="num" value="1" >
    <input type="button" value="+" onclick="add()">

    <script>
        function show(){
            alert("Hello wujiayu！！！")
        }
        function add(){
            var text = document.getElementById("num");
            console.log(text)
            console.log(text.value)
            text.value = (Number)(text.value )+1
        }
        function subtract(){
            var text = document.getElementById("num");
            if(!(text.value == 1)){
                text.value = (Number)(text.value )-1
            }
        }
        function update(){
            var text = document.getElementById("num");
            if(text.value <= 0){
                text.value = 1
            }

        }

        function alter1(){
            var text = document.getElementById("num");
            if(text.value == ''){
                text.value = ''
            }else if(text.value <= 0){
                text.value = 1
            }

        }



    </script>
</body>
</html>
